<!-- 点位分析 -->
<template>
    <el-drawer
        custom-class="point-analysis"
        title="点位分析"
        :model-value="modelValue"
        :size="1030"
        @closed="handleClose"
    >
        <p v-if="pointAna.reason.length">该点位无法调度（{{ pointAna.reason }}）</p>
        <XcTable
            id="xc-table"
            :loading="tableLoading"
            :data="pointAna.planList"
            :columns="isShowExclude ? tableColumns1 : tableColumns2"
        >
        </XcTable>
    </el-drawer>
</template>

<script setup lang="ts">
import { ref, defineProps, defineEmits, computed } from 'vue';
import XcTable from '@x-tech/fe-pc-components/src/components/XcTableTemplate/XcTable.vue';

const emits = defineEmits<{(e: 'update:modelValue', visible: boolean): void; (e: 'success'): void }>();
const props = defineProps({
    modelValue: {
        type: Boolean,
        default: false,
    },
    pointAna: {
        type: Object,
        default: () => {
            return { planList: [], reason: '' };
        },
    },
});
const isShowExclude = computed(() => props.pointAna.reason.includes('方案排斥'));
const tableLoading = ref(false);
const tableColumns1 = [
    { label: '方案名称', key: 'name', prop: { width: '230', fixed: 'left' } },
    { label: '方案状态', key: 'statusName', prop: { width: '200' } },
    { label: '排斥类型', key: 'excludeTypeName', render: true, prop: { width: '200' } },
    { label: '时长', key: 'secondsName', prop: { width: '100' } },
    { label: '频次', key: 'numbersName', prop: { width: '150' } },
    { label: '投放周期', key: 'putInPeriod', prop: { width: '300' } },
];
const tableColumns2 = [
    { label: '方案名称', key: 'name', prop: { width: '230', fixed: 'left' } },
    { label: '方案状态', key: 'statusName', prop: { width: '200' } },
    { label: '时长', key: 'secondsName', prop: { width: '100' } },
    { label: '频次', key: 'numbersName', prop: { width: '150' } },
    { label: '投放周期', key: 'putInPeriod', prop: { width: '300' } },
];
const handleClose = () => {
    emits('update:modelValue', false);
};
</script>

<style lang="scss" scoped></style>
